﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Windvoice.Blog;

namespace Windvoice.Controllers
{
    public class BlogController : ApiController
    {
        // GET api/blog
        //[HttpGet]
        public IEnumerable<Article> Get()
        {
            int recordCount = 0;
            return Article.GetList(1, int.MaxValue, 0, out recordCount);
        }

        // GET api/blog/5
        //[HttpGet]
        public Article Get(string key)
        {
            return Article.Get(key);
        }

        // POST api/blog
        [HttpPost]
        public void Post([FromBody]Article article)
        {
            article.CreateAndFlush();
        }

        // PUT api/blog/5
        [HttpPut]
        public void Put([FromBody]Article article)
        {
            article.UpdateAndFlush();
        }

        // DELETE api/blog/5
        [HttpDelete]
        public void Delete(string key)
        {
            Article.Delete(key);
        }
    }
}
